package com.lc.demo.mapper;

import com.lc.demo.bean.Cart;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.BaseMapper;

import java.util.List;

/**
 * @Author: sakila
 * @Date: 2022/03/07/19:32
 * @Description:
 */
public interface CartMapper extends BaseMapper<Cart> {

    @Select("select * from t_cart where userId=#{id} ")
    List<Cart> getCartList(@Param("id") Integer id);


    @Select("select * from t_cart where userId=#{id} and goodsId={goodsId}")
    Cart selectGood(@Param("goodsId") Integer goodsId, @Param("id") Integer id);

    @Update("update  t_cart set goodsNum= goodsNum+#{goodsNum} where userId=#{id} and goodsId=#{goodsId} ")
    void changeCart(@Param("goodsNum") Integer goodsNum, @Param("goodsId") Integer goodsId, @Param("id") Integer id);
}
